{% extends "base.html" %}

{% load authnames crispy_forms_tags i18n translations %}

{% block breadcrumbs %}
  <li class="breadcrumb-item">
    <a href="{% url 'login' %}">{% translate "Sign in" %}</a>
  </li>
{% endblock breadcrumbs %}

{% block content %}

  <div class="container">

    {% if form.errors %}
      {% translate "This username/password combination was not found. Please try again." as msg %}
      {% show_message "error" msg %}
    {% endif %}

    <h2>{% include "accounts/snippets/login-title.html" %}</h2>
    <div class="row">


      <div class="col-sm-6 order-sm-2">

        <h4>
          {% format_site_title as formatted_site_title %}
          {% blocktranslate %}Sign in to {{ formatted_site_title }}{% endblocktranslate %}
        </h4>
        <div class="card">
          <div class="card-body">
            {% if show_login_form %}
              <form method="post" action="{% url 'login' %}">
                {% csrf_token %}
                {{ form|crispy }}

                <input type="hidden" name="next" value="{{ next }}" />

                <input type="submit"
                       value="{% translate "Sign in" %}"
                       class="btn btn-primary btn-full" />
              </form>
            {% endif %}

            {% if login_backends %}

              <h5 class="login-label">{% translate "Sign in with:" %}</h5>
              <div class="container-fluid">
                <div class="row row-cols-md-2 row-cols-1">
                  {% for name in login_backends %}
                    <div class="col btn-auth">
                      <a href=""
                         class="btn btn-outline-primary link-post"
                         data-href="{% url 'social:begin' name %}"
                         {% if next %}data-params='{"next": "{{ next|escapejs }}"}'{% endif %}>{% auth_name name " " %}</a>
                    </div>
                  {% endfor %}
                </div>
              </div>

            {% endif %}

            {% if can_reset or registration_open %}
              <div class="clearfix"></div>
              <ul class="login-links">
                {% if can_reset %}
                  <li>
                    <a href="{% url 'password_reset' %}">{% translate "Forgot your password?" %}</a>
                  </li>
                {% endif %}

                {% if registration_open %}
                  <li>
                    <a href="{% url 'register' %}">{% translate "Register new account" %}</a>
                  </li>
                {% endif %}
              </ul>
            {% endif %}



          </div>
        </div>

      </div>

      <div class="col-sm-6 order-sm-1">{% include "accounts/snippets/login-info.html" %}</div>

    </div>
  </div>

{% endblock content %}
